const request = require("/util/request")


// 小程序首页
export function home(){
    return request({
        url:'appSysHome/find',
        method:'GET'
    })
}
// 小程序分类
export function type(){
    return request({
        url:'product-type/all',
        method:'GET'
    })
}

// 查询优惠券
export function couponUser() {
    return request({
        url: `couponUser/app/query/count`,
        method: 'GET',
    })
}

// 查询收藏夹
export function favorites() {
    return request({
        url: 'product/app/favorites',
        method: 'GET',
    })
}

// 查看推荐
export function eventsGoods(){
    return request({
        url: 'appSysHome/find/eventsGoods',
        method: 'GET',
    })
}

// 上传
export function uploadFile(path){
    return new Promise((resolve,reject)=>{
        my.uploadFile({
            url: "https://www.zzl.mkxzuji.cn/api/file/upload",
            fileType: 'image',
            fileName: 'file',
            filePath: path,
            formData: {
                path: 'mini'
            },
            header: {
                'Content-Type': 'multipart/form-data', // 只能是这种形式
            },
            success: res => {
                resolve(res)
            },
            fail: err => {
                console.log(err)
                my.showToast({
                    content: '请重新上传', // 文字内容
                });
            }
        })
    })
}

// 查看推荐
export function qrCodeCount(account){
    const countAdd = request({
        url: `sys/flowData/${account}/qrCodeCountAdd`,
        method: 'GET',
        hiddenTip:true
    })
    const peopleCountAdd = request({
        url: `sys/flowData/${account}/qrCodePeopleCountAdd`,
        method: 'GET',
        hiddenTip:true
    })

    return Promise.all([countAdd,peopleCountAdd])
}

